<?php

namespace App\Listeners\TopicRestored;

use App\Events\TopicRestored;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use App\Notifications\TopicRestored as NotificationTopicRestored;

class SendNotification
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  TopicRestored  $event
     * @return void
     */
    public function handle(TopicRestored $event)
    {
        $topic = $event->topic;
        $operator = $event->operator;
        /** @var \App\Models\User $user */
        $user = $topic->user;
        $user->notify(new NotificationTopicRestored($topic, $operator));
        $log = sprintf("%s, send %s to user: %s", __METHOD__, NotificationTopicRestored::class, $user->id);
        logger($log);
    }
}
